<?php
	session_start();
	require_once('functions.php');
	
	if( $_SESSION['account_type_code'] != 1) 
	{
		header("Location:index.php?response_msg=Please login.");
		exit;
	}
	
	$boatid = $_REQUEST['boat_id'];
	$boatname = $_REQUEST['boat_name'];
	$boatcolor = $_REQUEST['boat_color'];

	if(!$boatname || !$boatcolor )
	{	
		$error_msg = "Please fill in all the values.";
	}
	
	if(!$boatid )
	{	
		$error_msg = "Error - invalid boat.";
	}
	
	if($error_msg)
	{
		header("Location:admin.php?response_msg=".$error_msg);
		exit;
	}
	else
	{
		if( update_boat($boatid, $boatname, $boatcolor) )
		{
			header("Location:admin.php?response_msg=Boat information updated.");
			exit;
		}
		else
		{
			header("Location:admin.php?response_msg=An error has occurred. Boat info could not be updated.");
			exit;
		}
	}
?>